﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ORMDemo.Core.DBFilter
{
    public static class DBFilterExtend
    {
        public static IEnumerable<PropertyInfo> GetPropertiesWithNokey(this Type t)
        {
            return t.GetProperties().Where(p => !p.IsDefined(typeof(PrimaryKeyAttribute),true));
        }
        public static PropertyInfo GetPropertiesWithkey(this Type t)
        {
            var prop = t.GetProperties().Where(p => p.IsDefined(typeof(PrimaryKeyAttribute), true)).FirstOrDefault();
            if (prop == null)
                return t.GetProperty("Id");
            else
                return prop;
        }
    }
}
